#include <core/types.h>
#include <core/io.h>
#include <autoconf.h>


BYTE GkUartReadByte(void)
{
#ifdef UART_ENABLE_FIFO
	while (!(ReadLong(CURR_UART_BASE + UFSTAT) & 0xf));
#else
	while (!(ReadLong(CURR_UART_BASE + UTRSTAT) & 0x1));
#endif

	return ReadByte(CURR_UART_BASE + URX);
}

UINT32 GkGetUartStatus(void)
{
#ifdef UART_ENABLE_FIFO
		return (ReadLong(CURR_UART_BASE + UFSTAT) & 0xf);
#else
		return (ReadLong(CURR_UART_BASE + UTRSTAT) & 0x1);
#endif
}

void GkUartWriteByte(BYTE bData)
{
#ifdef UART_ENABLE_FIFO
	while (ReadLong(CURR_UART_BASE + UFSTAT)& 0x200);
#else
	while (!(ReadLong(CURR_UART_BASE + UTRSTAT)& 0x2));
#endif

	WriteByte(bData, CURR_UART_BASE + UTX);
}

